<template>
  <div class="p-4">
    <BasicTable @register="registerTable">
      <template #action="{ record }">
        <TableAction
          :actions="[
            {
              label: '查看任务',
              icon: 'ant-design:file-search-outlined',
              onClick: handleDelete.bind(null, record),
            },

          ]"
        />
      </template>
    </BasicTable>
  </div>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import { BasicTable, useTable, BasicColumn, TableAction } from '/@/components/Table';

  import { demoListApi } from '/@/api/learningcorner/task';
  import { useRouter } from 'vue-router';
  import { string } from 'vue-types';
  const columns: BasicColumn[] = [
    {
      title: '任务名',
      dataIndex: 'title',
    },
    {
      title:'任务简述',
      dataIndex:'sketch',
    },
    {
      title:'任务发起人',
      dataIndex:'jrid',
      width:160,
    },
    {
      title:'任务状态',
      dataIndex:'status',
      width:160,
    }
  ];
  export default defineComponent({
    components: { BasicTable, TableAction },
    setup() {
    const { replace } = useRouter();
      const [registerTable] = useTable({
        title: '任务中心',
        api: demoListApi,
        columns: columns,
        rowSelection: { type: 'radio' },
        bordered: true,
        actionColumn: {
          width: 160,
          title: 'Action',
          dataIndex: 'action',
          slots: { customRender: 'action' },
        },
      });
      function handleDelete(record: Recordable) {
        console.log('点击了删除', record.id);


        const file = record.id

        console.log(file)


    replace({
      path: '/' + "task/submit",
      query: {id:file},
    });


      };
      return {
        registerTable,
        handleDelete,
      };
    },
  });
</script>
